<?php

namespace action;
use common\action\Site AS Action;

abstract class BaseDoc extends Action {
    
    /**
    * put your comment there...
    * 
    * @return \model\all\All
    */
    protected function getModel(){}

    protected function getMenu($info){
        $model = $this->getModel();
        $cond = [
           'pid' => 0,
            '_order' => 'chapter'
        ];
        $menu = $model->find($cond);
        $this->assign('menu', $menu);
        $this->assign('currentMenu', $info);
    }

    protected function getInfo(){
        $searchKey = I()->getVar('searchKey');
        $current = $search = null;
        $model = $this->getModel();
        if($searchKey && $_POST){
            if($searchKey){
                $cond = [
                    'searchKey' => $searchKey,
                ];
                $search = $model->find($cond);
            }
        }

        $this->assign('search', $search);
        $this->assign('searchKey', $searchKey);
        if(!$search){
            $id = I()->getInt('id', I()->getInt('pid', 1));
            if($id){
                $current = $model->getInfo($id);
            }
        }

        return $current;
    }
}